<%-- 
    Document   : getmetricsRUP
    Created on : 11/Abr/2010, 22:10:39
    Author     : luis
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"
    import="pt.our.angemc.parser.*"
    import="pt.our.angemc.datatypes.*"
    import="org.json.*"
    import="java.util.HashMap"

%>

<%
    JSONObject obj = new JSONObject();

    String text = request.getParameter("text");
    Parser2 p = new Parser2();

    if(p.checkGrammar(text).equals("0"))
    {
        HashMap<String,Object> metrics = p.getGrammarRUP(text).predictModificationMetrics();
        
        obj.put("success", true);
        obj.put("terms", metrics.get("terminalsCount"));
        obj.put("nterms", metrics.get("nonTerminalsCount"));
        obj.put("prods", metrics.get("productionsCount"));
        obj.put("uprods", metrics.get("unitaryProductionsCount"));
        obj.put("recs", metrics.get("recursiveCount"));
        obj.put("rhs", metrics.get("rhsCount"));
        obj.put("alts", metrics.get("alternativesCount"));
        obj.put("rd", metrics.get("rdCount"));
        obj.put("ll1", metrics.get("ll1Count"));
    }
    else
    {
        obj.put("success", false);
    }

    out.print(obj);

%>
